<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人和人律师事务所管理系统v1.0-案件信息查询</title>

<style type="text/css" media="all">
    .allow-float {clear:none!important;} /* 允许该元素浮动 */
    .stop-float {clear:both!important;} /* 阻止该元素浮动 */
	.float-left {float:left;padding-left:10px}   /*浮动到左边*/
  </style>
  <!-- 引入图形化报表JS代码 -->
<script type="text/javascript" src="caseJs/lawyerPerformanceChart.js"></script>
  <!-- 引入结案JS代码 -->
<script type="text/javascript" src="caseJs/settle_case_info.js"></script>
  <!-- 引入案件类别报表JS代码 -->
<script type="text/javascript" src="caseJs/case_type_chart.js"></script>
  <!-- 引入提示信息JS代码 -->
<script type="text/javascript" src="caseJs/case_point_info.js"></script>
  <!-- 引入所业绩查看JS代码 -->
<script type="text/javascript" src="caseJs/office_performance_info.js"></script>

<script type="text/javascript">

Ext.onReady(function(){
	//修改案件信息面板
	var mcaseInfoForm;
	var royaltyWin;
	Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
    Ext.QuickTips.init();
	//设定超时时间
    Ext.Ajax.timeout=120000;
    Ext.form.Field.prototype.msgTarget = 'side';

     var lawyerbutton=false;
	//是否具有查询权限
			<%
			if((Integer)session.getAttribute("popedomLevel")==3){
			%>
			lawyerbutton=true;
			<%
			}%>

    //查询框
    var searchCaseWindow = new Ext.form.FormPanel({

    		labelAlign:'right',
			title:'案件信息查询',
			labelSeparator :'：',//分隔符
			labelWidth : 100,//标签宽度
			bodyStyle:'padding:5',//表单边距
			frame : true,
			collapsible: true,
			height:100,
			width:window.screen.width-225,
			applyTo :'searchCaseWin',
			defaults:{
			width:200
			},
			items:[
				new Ext.form.TextField({
					fieldLabel : '合同号',
					id : 'contractName',
					name : 'contractName',
					width:(window.screen.width-220)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),

				new Ext.form.DateField({
					fieldLabel : '签订时间介于',
					format:'Y-m-d',
					id : 'signTimeS',
					name : 'signTimeS',
				width:(window.screen.width-220)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					allowBlank : true
				}),

				new Ext.form.DateField({
					fieldLabel : '与',
					format:'Y-m-d',
					id : 'signTimeE',
					name : 'signTimeE',
					width:(window.screen.width-220)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),

			new Ext.form.TextField({
							fieldLabel : '承办律师',
							id : 'undertakeLawyer',
							name : 'undertakeLawyer',
							disabled:lawyerbutton,
							width:(window.screen.width-220)*0.18,
							itemCls:'float-left',//向左浮动
							clearCls:'allow-float',//允许浮动
							selectOnFocus : true,//得到焦点时自动选择文本
							allowBlank : true
						}),

				new Ext.Button({
					text : '开始查询',
					autoWidth:true,
					iconCls:'search',
					cls:'float-left',//向左浮动
					handler : submitMsg
				})
			]

		})


		//查询处理函数
	function submitMsg(){
		var contractName=Ext.getCmp("contractName").getValue();
		var signTimeS=Ext.getCmp("signTimeS").value;
		var signTimeE=Ext.getCmp("signTimeE").value;
		var undertakeLawyer=Ext.getCmp("undertakeLawyer").getValue();

		 store = new Ext.data.JsonStore({
				url:"SearchCaseInfo.jsj?contractName="+contractName+"&signTimeS="+signTimeS+"&signTimeE="+signTimeE
				+"&undertakeLawyer="+undertakeLawyer,
				totalProperty: 'totalCount',
			    root: 'result',
				fields:["contractnumber","casesigntime","casetype","caseproperty","caseconsigner","identitynumber","phonenumber","oppositeparty",
				"affaircause","casemoney","gatherperson","casebill","archivedeposit","contracttext","letterauthor","courtoffletter","checkoffletter",
				"courtday","introletter","lawyersletter","interviewletter","othertext","settlelawsuit","caseremark","casepaystatus",
				"undertakelawyer","caser_roy_money","lawyermoney","paymoney","paystatusbreif","undertakebrief"]
			});

		store.reload({
			params:{
				start:0,
				limit:5
				}
			});

		var colModel = new Ext.grid.ColumnModel([//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "合同号", width: 100, dataIndex: 'contractnumber', sortable: true},
				{header: "签订时间", width: 100, dataIndex: 'casesigntime', sortable: true},
				{header: "开庭时间", width: 100, dataIndex: 'courtday', sortable: true},
				{header: "案件类别", width: 75, dataIndex: 'casetype', sortable: true},
				{header: "案件性质", width: 75, dataIndex: 'caseproperty', sortable: true},
				{header: "委托人", width: 75, dataIndex: 'caseconsigner', sortable: true},
				{header: "身份证号", width: 150, dataIndex: 'identitynumber', sortable: true},
				{header: "联系电话", width: 100, dataIndex: 'phonenumber', sortable: true},
				{header: "对方当事人", width: 75, dataIndex: 'oppositeparty', sortable: true},
				{header: "案由", width: 200, dataIndex: 'affaircause', sortable: true},
				{header: "合同金额", width: 75, dataIndex: 'casemoney', sortable: true},
				{header: "已付款总金额", width: 120, dataIndex: 'paymoney', sortable: true},
				{header: "付款情况", width: 350, dataIndex: 'casepaystatus', sortable: true},
				{header: "付款情况备注", width: 200, dataIndex: 'paystatusbreif', sortable: true},
				{header: "承办律师", width: 100, dataIndex: 'undertakelawyer', sortable: true},
				{header: "承办律师备注", width: 150, dataIndex: 'undertakebrief', sortable: true},
				{header: "承办律师提成总金额", width: 120, dataIndex: 'lawyermoney', sortable: true},
				{header: "采集人", width: 75, dataIndex: 'gatherperson', sortable: true},
				{header: "采集人提成总金额", width: 75, dataIndex: 'caser_roy_money', sortable: true},
				{header: "票据", width: 75, dataIndex: 'casebill', sortable: true},
				{header: "卷宗押金收退情况(0:已收 1:已退 2:未收)", width: 250, dataIndex: 'archivedeposit', sortable: true},
				{header: "合同文本", width: 100, dataIndex: 'contracttext', sortable: true},
				{header: "授权委托书", width: 120, dataIndex: 'letterauthor', sortable: true},
				{header: "法院公函", width: 200, dataIndex: 'courtoffletter', sortable: true},
				{header: "检察院公函", width: 200, dataIndex: 'checkoffletter', sortable: true},
				{header: "介绍信", width: 150, dataIndex: 'introletter', sortable: true},
				{header: "律师函", width: 150, dataIndex: 'lawyersletter', sortable: true},
				{header: "会见函", width: 150, dataIndex: 'interviewletter', sortable: true},
				{header: "其他文本", width: 150, dataIndex: 'othertext', sortable: true},
				{header: "结案(0:已结 1:未结)", width: 200, dataIndex: 'settlelawsuit', sortable: true},
				{header: "备注", width: 200, dataIndex: 'caseremark', sortable: true},
				]);

				pagebar.bind(store);
				grid.reconfigure(store,colModel);
				grid.getView().refresh(true);
	}

   		 //存储器
		var store = new Ext.data.JsonStore({
					url:"CaseInfoSearch.jsj",
					totalProperty: 'totalCount',
					root: 'result',
					fields:["contractnumber","casesigntime","casetype","caseproperty","caseconsigner","identitynumber","phonenumber","oppositeparty",
					"affaircause","casemoney","gatherperson","casebill","archivedeposit","contracttext","letterauthor","courtoffletter","checkoffletter",
					"courtday","introletter","lawyersletter","interviewletter","othertext","settlelawsuit","caseremark","casepaystatus",
					"undertakelawyer","caser_roy_money","lawyermoney","paymoney","paystatusbreif","undertakebrief"]
				});

		store.load({
			params:{
				start:0,
				limit:5
				}
			});

		//获得用户权限
		var buttonDisabled=true;
	<%
	if((java.lang.Integer)session.getAttribute("popedomLevel")==1){
		%>
		buttonDisabled=false;
	<%
	}
	%>

		//创建工具栏组件
		var toolbar = new Ext.Toolbar([
			{text : '律师基本信息'},
			'-',
			{
			text:'查看付款,提成实际情况',
			iconCls:'search',
			handler:function(btn,pressed){
			searchDetailRolety();
			}
			},
			'-',
			{
			text:'律师业绩查看',
			iconCls:'search',
			handler:function(btn,pressed){
			lawyerPerformanceFun();
			}
			},
			'-',
			{
			text:'律师业绩图形报表',
			iconCls:'search',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			lawyerChartFun();
			}
			},
			'-',
			{
			text:'案件类别报表',
			iconCls:'search',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			caseTypeChartFun();
			}
			},
			'-',
			{
			text:'所业绩报表',
			iconCls:'search',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			officePerformanceFun();
			}
			},
			'-',
			{
			text:'律师提成',
			iconCls:'get',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			lawyerRoyalty();
			}
			},
			'-',
			{
			text:'付款',
			iconCls:'receive',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			payDetailInfoFun();
			}
			},
			'-',
			{
			text:'修改案件信息',
			iconCls:'option',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			modifyCaseInfo();
			}
			},
			'-',
			{
			text:'删除案件信息',
			iconCls:'remove',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			deleteCaseInfo();
			}
			},
			'-',
			{
			text:'结案',
			iconCls:'confirm',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			settleCaseFun(grid,store);
			}
			}

		]);


		//查看律师业绩面板
		var lawyerPerformancePanel
		//查看业绩窗口
		var lawyerPerformanceWin;
		//查看律师业绩处理函数
		function lawyerPerformanceFun(){
			//查看业绩窗口
			lawyerPerformanceWin=new Ext.Window({
				layout:'fit',
				width:400,
				height:300,
				closeAction:'hide',
				plain:true,
				title:'律师业绩查看窗口',
				items:lawyerPerformancePanel
			});
			lawyerPerformanceWin.show();
		}
		//查看律师业绩面板
		 lawyerPerformancePanel=new Ext.form.FormPanel({
			labelSeparator :'：',//分隔符
			labelWidth : 110,//标签宽度
			bodyStyle:'padding:5',//表单边距
			buttonAlign:'center',//按钮居中
			frame : true,
			collapsible: true,
			defaults : {
            width : 200
        },
        items : [
        {
        	xtype:'datefield',
        	format:'Y-m-d',
            fieldLabel :'开始时间',
			id :'lpstartTime',
			name :'lpstartTime',
			allowBlank :false
        },
        {
        	xtype:'datefield',
        	format:'Y-m-d',
            fieldLabel :'结束时间',
			id :'lpendTime',
			name :'lpendTime',
			allowBlank :false
        },
        new Ext.form.ComboBox({
			fieldLabel:'请选择律师',
			store:new Ext.data.JsonStore({
			url:'LawyerNamesRequest.jsj',
			totalProperty:'totalCount',
			root:'result',
			fields:["lawyerid","lawyername"]
			}),
			valueField:'lawyerid',
			displayField:'lawyername',
			forceSelection:true,
			emptyText:'请选择律师',
			hiddenName:'lpLawyerId',
			editable:false,
			triggerAction:'all',
			id:'lpguidteacher',
			name:'lpguidteacher'
			}),
        {
        	height:30
        },
        {
        	 xtype:'textfield',
        	 fieldLabel :'合同总金额',
			 id :'lpcontractMoney',
			 name :'lpcontractMoney',
			 allowBlank :true
        },
        {
        	 xtype:'textfield',
        	 fieldLabel :'已付款总金额',
			 id :'lppayMoney',
			 name :'lppayMoney',
			 allowBlank :true
        },
         {
         	 xtype:'textfield',
        	 fieldLabel :'律师提成总金额',
			 id :'lproyaltyMoney',
			 name :'lproyaltyMoney',
			 allowBlank :true
        }
        ],

        buttons : [ {
            text : '查看',
            iconCls:'search',
            disabled : false,
            handler : function() {
                if (lawyerPerformancePanel.form.isValid()) {
                    lawyerPerformancePanel.form.submit( {
                        url : 'LawyerPerformanceLook.jsj',
                        success : function(from, action) {
                        var result=action.result.message;
                        if(result=="sorry"){
                         Ext.MessageBox.alert('提示', "对不起，你只能查看你自己的业绩！");
                         }else{
                         var resultArr=result.split("|");
                           Ext.getCmp("lpcontractMoney").setValue(resultArr[0]);
                          Ext.getCmp("lppayMoney").setValue(resultArr[1]);
                          Ext.getCmp("lproyaltyMoney").setValue(resultArr[2]);
                         }
                        },
                        failure : function(form, action) {
                            var result=action.result.message;
                        if(result=="sorry"){
                         Ext.MessageBox.alert('提示', "对不起，你没有权限！");
                         }else{
                         var resultArr=result.split("|");
                           Ext.getCmp("lpcontractMoney").setValue(resultArr[0]);
                          Ext.getCmp("lppayMoney").setValue(resultArr[1]);
                          Ext.getCmp("lproyaltyMoney").setValue(resultArr[2]);
                         }
                        },
                        waitMsg : '正在发送请求，稍后...'
                    });
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        },{
        text:'取消',
        iconCls:'cancel',
        handler:function(){
        lawyerPerformanceWin.hide();
        }
        }
        ]
		})




		//查看付款与提成实际详情
		function searchDetailRolety(){
		//用户要查看的一项
		var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('查看操作','请选择要查看的一项！');
        } else {
                 Ext.getCmp("contractId").setValue(record.get("contractnumber"));
                 //显示窗口
            	 royaltyForm();
       		 }
		}

		//暂存合同ID
		var contractID=new Ext.form.TextField({
					id : 'contractId',
					name : 'contractId',
				});

		//提成与付款详情展示窗口
		var royaltyForm = function() {
            royaltyDetailWin = new Ext.Window( {
                layout : 'fit',
                width : 500,
                height : 320,
                closeAction : 'hide',
                plain : true,
                title : '付款与提成实际情况窗口',
                items : royaltyWin
            });
            //显示窗口
       		 royaltyDetailWin.show();
			//获得合同号
	        var dest=Ext.getCmp("contractId").getValue();
	        //加载数据
			royaltyWin.getForm().load({
			       	 url:'SearchDetailRolety.jsj?contractId='+dest,
			       	 waitMsg : '正在载入数据...',
			         success : function(form,action) {
					        		var message=action.result.message;
					        		var detailArray=message.split("|");
					        		Ext.getCmp("payStatus").setValue(detailArray[0]);
					                Ext.getCmp("royaltyDetails").setValue(detailArray[1]);
			                },
			         failure : function(form,action) {
				                  	var message=action.result.message;
				        		    var detailArray=message.split("|");
				        			Ext.getCmp("payStatus").setValue(detailArray[0]);
				                    Ext.getCmp("royaltyDetails").setValue(detailArray[1]);
			               }
	        });
	    };
	    	//详情PANEL
			royaltyWin = new Ext.FormPanel( {
						labelSeparator :'：',//分隔符
						labelWidth : 80,//标签宽度
						bodyStyle:'padding:5',//表单边距
						buttonAlign:'center',//按钮居中
						frame : true,
						collapsible: true,

				        defaults : {
				        	height:100,
				            width : 260
				        },
				        defaultType : 'textarea',

				        items : [
				        {
				            fieldLabel : '付款详情',
				            itemCls:'float-left',//向左浮动
							clearCls:'allow-float',//允许浮动
				            name :'payStatus',
				            id :'payStatus',
				            readOnly:true,
				            allowBlank :true
				        },
				         {
				            fieldLabel : '提成详情',
				            itemCls:'float-left',//向左浮动
							clearCls:'allow-float',//允许浮动
				            name :'royaltyDetails',
				            id:"royaltyDetails",
				             readOnly:true,
				            allowBlank : true
				        }
				        ],

				        buttons : [{
				            text : '确定',
				            iconCls:'confirm',
				            handler : function() {
				                royaltyDetailWin.hide();
				            }
				        }]
   			 });

		//律师提成处理
		function lawyerRoyalty(){
		var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('提成操作','请选择要提成的一项！');
        } else {
       			 //获得合同号
        	     Ext.getCmp("LawyercontractId").setValue(record.get("contractnumber"));
        	     //获得承办律师
        	     Ext.getCmp("rLawyerName").setValue(record.get("undertakelawyer"));
        	     //获得合同总金额
        	     Ext.getCmp("rContractMoney").setValue(record.get("casemoney"));
            	 lawyerRoyaltyWin();
        }
		}
		//律师提成窗口
		var lawyerRoyaltyWin = function() {
            lawyerRoyaltyWindows = new Ext.Window( {
                layout : 'fit',
                width : 400,
                height : 300,
                closeAction : 'hide',
                plain : true,
                title : '律师提成窗口',
                items : lawyerRoyaltyForm
            });
        lawyerRoyaltyWindows.show();
    };

    lawyerRoyaltyForm = new Ext.FormPanel( {
         collapsible : true,// 是否可以展开
        labelWidth : 75, // label settings here cascade unless overridden
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        buttonAlign:'center',//按钮居中
        waitMsgTarget : true,
        defaults : {
            width : 230
        },
        defaultType : 'textfield',

        items : [
        {
         	xtype:'hidden',
            name :'rContractMoney',
            id:"rContractMoney",

        },
        {
         	xtype:'hidden',
            name :'LawyercontractId',
            id:"LawyercontractId",

        },
         {
         	xtype:'hidden',
            name :'rLawyerName',
            id:"rLawyerName",

        },
         {
         	xtype:'datefield',
         	format:'Y-m-d',
            fieldLabel : '提成时间',
            name :'royaltyTime',
            id:"royaltyTime",
            allowBlank : false
        },
        {
            fieldLabel : '提成金额',
            name :'royaltyMoney',
            id:"royaltyMoney",
            allowBlank : false
        },
        {
         	xtype:'textarea',
            fieldLabel : '备注',
            name :'royaltyRemark',
            id:"royaltyRemark",
            allowBlank : true
        },
         {
         	inputType:'password',
            fieldLabel : '签名',
            name :'passWord',
            id:"passWord",
            width:140,
            allowBlank : false
        }
        ],

        buttons : [ {
            text : '提成',
            disabled : false,
            iconCls:'get',
            handler : function() {
                if (lawyerRoyaltyForm.form.isValid()) {
                    lawyerRoyaltyForm.form.submit( {
                        url : 'LawyerRoyaltyRequest.jsj',
                        success : function(from, action) {
                         Ext.MessageBox.alert('结果', action.result.message);
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            lawyerRoyaltyWindows.hide();
                        },
                        failure : function(form, action) {
                           Ext.MessageBox.alert('结果', action.result.message);
                           store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                           lawyerRoyaltyWindows.hide();
                        },
                        waitMsg : '正在提成，稍后...'
                    });
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        }, {
            text : '取消',
            iconCls:'cancel',
            handler : function() {
                lawyerRoyaltyWindows.hide();
            }
        }]
    });


		var payDetailInfoFunWindows;
		var payDetailInfoFunForm;

		//增加付款详情处理
		function payDetailInfoFun(){
		var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('付款操作','请选择要付款的一项！');
        } else {
       			 //获得合同号
        	     Ext.getCmp("payLawyercontractId").setValue(record.get("contractnumber"));
        	      //获得付款总金额
        	     Ext.getCmp("pContractMoney").setValue(record.get("casemoney"));
            	payDetailInfoFunWin();

        }
		}
		//增加付款详情
		var payDetailInfoFunWin = function() {
            payDetailInfoFunWindows = new Ext.Window( {
                layout : 'fit',
                width : 400,
                height : 200,
                closeAction : 'hide',
                plain : true,
                title : '增加付款详情',
                items : payDetailInfoFunForm
            });
        payDetailInfoFunWindows.show();
    };

    payDetailInfoFunForm = new Ext.FormPanel( {
         collapsible : true,// 是否可以展开
        labelWidth : 75, // label settings here cascade unless overridden
        frame : true,
        buttonAlign:'center',//按钮居中
        bodyStyle : 'padding:5px 5px 0',
        waitMsgTarget : true,
        defaults : {
            width : 230
        },
        defaultType : 'textfield',

        items : [
        {
         	xtype:'hidden',
            name :'pContractMoney',
            id:"pContractMoney",

        },
        {
         	xtype:'hidden',
            name :'payLawyercontractId',
            id:"payLawyercontractId",

        },
         {
         	xtype:'datefield',
         	format:'Y-m-d',
            fieldLabel : '付款时间',
            name :'payTime',
            id:"payTime",
            allowBlank : false
        },
        {
            fieldLabel : '付款金额',
            name :'payMoney',
            id:"payMoney",
            allowBlank : false
        },
        {
            fieldLabel : '备注',
            name :'payRemark',
            id:"payRemark",
            allowBlank : true
        }
        ],

        buttons : [ {
            text : '付款',
            iconCls:'receive',
            disabled : false,
            handler : function() {
                if (payDetailInfoFunForm.form.isValid()) {
                    payDetailInfoFunForm.form.submit( {
                        url : 'PayDetailInfoRequest.jsj',
                        success : function(from, action) {
                         Ext.MessageBox.alert('结果', action.result.message);
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            payDetailInfoFunWindows.hide();
                        },
                        failure : function(form, action) {
                           Ext.MessageBox.alert('结果', action.result.message);
                           store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                           payDetailInfoFunWindows.hide();
                        },
                        waitMsg : '正在提交，稍后...'
                    });
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        }, {
            text : '取消',
            iconCls:'cancel',
            handler : function() {
                payDetailInfoFunWindows.hide();
            }
        }]
    });



	//修改案件信息函数
		function modifyCaseInfo(){

		var record = grid.getSelectionModel().getSelected();
        if (!record) {

           Ext.MessageBox.alert('修改操作','请选择要修改的一项！');
        } else {
            caseInfoFunction();

                Ext.getCmp("contractnumber").setValue(record.get("contractnumber"));
            	Ext.getCmp("casesigntime").setValue(record.get("casesigntime"));
            	//获取案件类别
            	var caseTyp=record.get("casetype");
            	var caseTypeString;
            	if(caseTyp=="民事案件"){
            	caseTypeString="A";
            	}
            	if(caseTyp=="刑事案件"){
            	caseTypeString="B";
            	}
            	if(caseTyp=="非诉"){
            	caseTypeString="C";
            	}
            	if(caseTyp=="法律顾问"){
            	caseTypeString="D";
            	}
            	if(caseTyp=="咨询与代写法律文书"){
            	caseTypeString="E";
            	}
            	if(caseTyp=="行政诉讼"){
            	caseTypeString="F";
            	}
            	if(caseTyp=="仲裁"){
            	caseTypeString="G";
            	}

            	Ext.getCmp("casetype").setValue(caseTypeString);
            	//获取案件性质
            	var casePropert=record.get("caseproperty");
            	var casePropString;
            	if(casePropert=="自主案源"){
            	casePropString="a";
            	}
            	if(casePropert=="分配案源"){
            	casePropString="b";
            	}
            	Ext.getCmp("caseproperty").setValue(casePropString);
            	Ext.getCmp("caseconsigner").setValue(record.get("caseconsigner"));
            	Ext.getCmp("identitynumber").setValue(record.get("identitynumber"));
            	Ext.getCmp("phonenumber").setValue(record.get("phonenumber"));
            	Ext.getCmp("oppositeparty").setValue(record.get("oppositeparty"));
            	Ext.getCmp("affaircause").setValue(record.get("affaircause"));
            	Ext.getCmp("casemoney").setValue(record.get("casemoney"));
            	Ext.getCmp("gatherperson").setValue(record.get("gatherperson"));
            	Ext.getCmp("casebill").setValue(record.get("casebill"));
            	Ext.getCmp("archivedeposit").setValue(record.get("archivedeposit"));
                Ext.getCmp("contracttext").setValue(record.get("contracttext"));
                Ext.getCmp("letterauthor").setValue(record.get("letterauthor"));
                Ext.getCmp("courtoffletter").setValue(record.get("courtoffletter"));
                Ext.getCmp("checkoffletter").setValue(record.get("checkoffletter"));
                Ext.getCmp("courtday").setValue(record.get("courtday"));
                Ext.getCmp("introletter").setValue(record.get("introletter"));
                Ext.getCmp("lawyersletter").setValue(record.get("lawyersletter"));
                Ext.getCmp("interviewletter").setValue(record.get("interviewletter"));
                Ext.getCmp("othertext").setValue(record.get("othertext"));
                Ext.getCmp("settlelawsuit").setValue(record.get("settlelawsuit"));
                Ext.getCmp("caseremark").setValue(record.get("caseremark"));
                Ext.getCmp("casepaystatus").setValue(record.get("casepaystatus"));
                Ext.getCmp("undertakelawyer").setValue(record.get("undertakelawyer"));
                Ext.getCmp("caser_roy_money").setValue(record.get("caser_roy_money"));
                 Ext.getCmp("casepaystatusbreif").setValue(record.get("paystatusbreif"));
                  Ext.getCmp("undertakelawyerbrief").setValue(record.get("undertakebrief"));

        }
		}

		//修改案件信息窗口
		var caseInfoFunction = function() {
            caseInfoWindow = new Ext.Window( {
                layout : 'fit',
                width : 800,
                height : 500,
                closeAction : 'hide',
                plain : true,
                title : '修改案件信息窗口',
                items : mcaseInfoForm
            });
        caseInfoWindow.show();
    };

    mcaseInfoForm = new Ext.FormPanel( {
         collapsible : true,// 是否可以展开
        labelWidth : 120,
        labelAlign:'right',
        frame : true,
        buttonAlign:'center',//按钮居中
        bodyStyle : 'padding:5px 5px 0',
        waitMsgTarget : true,

        defaults : {
            width : 230
        },
        defaultType : 'textfield',
        items : [

        {
            fieldLabel : '合同号',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
			readOnly:true,
            name :'contractnumber',
             id :'contractnumber',
            allowBlank :false
        },

        {
        	xtype:'datefield',
        	format:'Y-m-d',
            fieldLabel : '签订时间',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'casesigntime',
            id :'casesigntime',
            allowBlank :false
        },

        {
	         fieldLabel :'案件类别',
			 id :'casetype',
			 name :'casetype',
			 itemCls:'float-left',//向左浮动
			 clearCls:'allow-float',//允许浮动
			 allowBlank :false
        },
        {
            fieldLabel : '案件性质',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'caseproperty',
            id:"caseproperty",
            allowBlank : false
        },
        {
            fieldLabel : '委托人',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'caseconsigner',
            id:"caseconsigner",
            allowBlank : false
        },
        {
            fieldLabel : '身份证号',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'identitynumber',
            id:"identitynumber",
            allowBlank : false
        },
         {
            fieldLabel : '联系方式',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'phonenumber',
            id:"phonenumber",
            allowBlank : false
        },
        {
            fieldLabel : '对方当事人',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'oppositeparty',
            id:"oppositeparty",
            allowBlank : false
        },

        {
            fieldLabel : '案由',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'affaircause',
            id:"affaircause",
            allowBlank : false
        },
         {
            fieldLabel : '合同金额',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'casemoney',
            id:"casemoney",
            allowBlank : false
        },
        {
            fieldLabel : '付款情况',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'casepaystatus',
            id:"casepaystatus",
            allowBlank : false
        },
        {
            fieldLabel : '付款情况备注',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'casepaystatusbreif',
            id:"casepaystatusbreif",
            allowBlank : false
        },
         {
            fieldLabel : '承办律师',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'undertakelawyer',
            id:"undertakelawyer",
            allowBlank : false
        },
        {
            fieldLabel : '承办律师备注',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'undertakelawyerbrief',
            id:"undertakelawyerbrief",
            allowBlank : false
        },
         {
            fieldLabel : '采集人',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'gatherperson',
            id:"gatherperson",
            allowBlank : true
        },
        {
            fieldLabel : '采集人提成金额',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'caser_roy_money',
            id:"caser_roy_money",
            allowBlank : true
        },

         {
            fieldLabel : '票据',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'casebill',
            id:"casebill",
            allowBlank : false
        },
         {
            fieldLabel : '卷宗押金收退情况',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'archivedeposit',
            id:"archivedeposit",
            allowBlank : false
        },
        {
            fieldLabel : '合同文本',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'contracttext',
            id:"contracttext",
            allowBlank : false
        },
        {
            fieldLabel : '授权委托书',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'letterauthor',
            id:"letterauthor",
            allowBlank : false
        },
        {
            fieldLabel : '法院公函',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'courtoffletter',
            id:"courtoffletter",
            allowBlank : false
        },
        {
            fieldLabel : '检察院公函',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'checkoffletter',
            id:"checkoffletter",
            allowBlank : false
        },
        {
        	xtype:'datefield',
        	format:'Y-m-d',
            fieldLabel : '开庭时间',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'courtday',
            id:"courtday",
            allowBlank : false
        },
        {
            fieldLabel : '介绍信',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'introletter',
            id:"introletter",
            allowBlank : false
        },
        {
            fieldLabel : '律师函',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'lawyersletter',
            id:"lawyersletter",
            allowBlank : false
        },
        {
            fieldLabel : '会见函',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'interviewletter',
            id:"interviewletter",
            allowBlank : false
        },
        {
            fieldLabel : '其他文本',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'othertext',
            id:"othertext",
            allowBlank : false
        },
        {
            fieldLabel : '结案',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'settlelawsuit',
            id:"settlelawsuit",
            allowBlank : false
        },
		 {
            fieldLabel : '备注',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'caseremark',
            id:"caseremark",
            allowBlank : false
        }
        ],

        buttons : [ {
            text : '保存',
            iconCls:'save',
            disabled : false,
            handler : function() {
                if (mcaseInfoForm.form.isValid()) {
                    mcaseInfoForm.form.submit( {
                        url : 'ModifyCaseInfo.jsj',
                        success : function(from, action) {
                         Ext.MessageBox.alert('修改结果', action.result.message);
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            caseInfoWindow.hide();
                        },
                        failure : function(form, action) {
                             Ext.MessageBox.alert('修改结果', action.result.message);
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            caseInfoWindow.hide();
                        },
                        waitMsg : '正在保存数据，稍后...'
                    });
                   // dialog.hide();
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        }, {
            text : '取消',
            iconCls:'cancel',
            handler : function() {
                caseInfoWindow.hide();
            }
        }]
    });




//删除案件信息函数
	function deleteCaseInfo(){
	var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('删除操作','请选择要删除的一项！');
        } else {
            deleteCaseWin();
              Ext.getCmp("contractId").setValue(record.get("contractnumber"));
	}
	}

		//删除案件信息窗口
		var deleteCaseWin=function(){
		Ext.MessageBox.confirm("删除","确认要删除吗？",deleteDispose)
    };


		//删除案件信息处理函数
		function deleteDispose(btn){
		if(btn=='yes'){
		var contractId=Ext.getCmp("contractId").getValue();
		var requestConfig = {
			url :'DeleteCaseInfo.jsj?contractId='+contractId,//请求的服务器地址
			success:function(response,options){
                        var jsonObj=Ext.util.JSON.decode(response.responseText);
                       Ext.MessageBox.alert("结果",jsonObj.message);
                       //重新加载数据
                       store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                       },
                       failure:function(response,ooptions){
                        var jsonObj=Ext.util.JSON.decode(response.responseText);
                       Ext.MessageBox.alert("结果",jsonObj.message);
                        //重新加载数据
                       store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                       }
			}
		}
		Ext.Ajax.request(requestConfig);//发送请求

		}

		//分页工具栏
		var pagebar = new Ext.PagingToolbar({
			store : store,
			pageSize : 5,
			displayInfo : true,
			displayMsg : '第 {0} ~ {1} 条 共 {2} 条',
			emptyMsg : '当前没有记录'
		});
		//创建选择模式对象
	var cb = new Ext.grid.CheckboxSelectionModel()
	//创建Grid表格组件
	var grid = new Ext.grid.GridPanel({
			renderTo : 'case-detail-info',
			frame : true,
			tbar : toolbar,
			bbar : pagebar,
			trackMouseOver:true, //鼠标特效
			loadMask: true,    //是否显示正在加载
			store : store,
			height : 280,
			width : window.screen.width-220,
			stripeRows : true,
			autoScroll : true,
			viewConfig : {autoFill : false},
			sm : cb,
			columns: [//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "合同号", width: 100, dataIndex: 'contractnumber', sortable: true},
				{header: "签订时间", width: 100, dataIndex: 'casesigntime', sortable: true},
				{header: "开庭时间", width: 100, dataIndex: 'courtday', sortable: true},
				{header: "案件类别", width: 75, dataIndex: 'casetype', sortable: true},
				{header: "案件性质", width: 75, dataIndex: 'caseproperty', sortable: true},
				{header: "委托人", width: 75, dataIndex: 'caseconsigner', sortable: true},
				{header: "身份证号", width: 150, dataIndex: 'identitynumber', sortable: true},
				{header: "联系电话", width: 100, dataIndex: 'phonenumber', sortable: true},
				{header: "对方当事人", width: 75, dataIndex: 'oppositeparty', sortable: true},
				{header: "案由", width: 200, dataIndex: 'affaircause', sortable: true},
				{header: "合同金额", width: 75, dataIndex: 'casemoney', sortable: true},
				{header: "已付款总金额", width: 120, dataIndex: 'paymoney', sortable: true},
				{header: "付款情况", width: 350, dataIndex: 'casepaystatus', sortable: true},
				{header: "付款情况备注", width: 200, dataIndex: 'paystatusbreif', sortable: true},
				{header: "承办律师", width: 100, dataIndex: 'undertakelawyer', sortable: true},
				{header: "承办律师备注", width: 150, dataIndex: 'undertakebrief', sortable: true},
				{header: "承办律师提成总金额", width: 120, dataIndex: 'lawyermoney', sortable: true},
				{header: "采集人", width: 75, dataIndex: 'gatherperson', sortable: true},
				{header: "采集人提成总金额", width: 75, dataIndex: 'caser_roy_money', sortable: true},
				{header: "票据", width: 75, dataIndex: 'casebill', sortable: true},
				{header: "卷宗押金收退情况(0:已收 1:已退 2:未收)", width: 250, dataIndex: 'archivedeposit', sortable: true},
				{header: "合同文本", width: 100, dataIndex: 'contracttext', sortable: true},
				{header: "授权委托书", width: 120, dataIndex: 'letterauthor', sortable: true},
				{header: "法院公函", width: 200, dataIndex: 'courtoffletter', sortable: true},
				{header: "检察院公函", width: 200, dataIndex: 'checkoffletter', sortable: true},
				{header: "介绍信", width: 150, dataIndex: 'introletter', sortable: true},
				{header: "律师函", width: 150, dataIndex: 'lawyersletter', sortable: true},
				{header: "会见函", width: 150, dataIndex: 'interviewletter', sortable: true},
				{header: "其他文本", width: 150, dataIndex: 'othertext', sortable: true},
				{header: "结案(0:已结 1:未结)", width: 200, dataIndex: 'settlelawsuit', sortable: true},
				{header: "备注", width: 200, dataIndex: 'caseremark', sortable: true},
				]
		});
});

</script>
</head>
<body>
<table><tr><td>
<div id='searchCaseWin' style="margin:8px 8px 4px 8px"></div>
</td></tr>
</table>
<div id='case-detail-info' style="margin:4px 8px 8px 8px"></div>


</body>
</html>